package CTRLayer;
import ModelLayer.Product;
import DBLayer.DBProduct;

public class ProductCTR 
{
	private DBProduct dbProduct;
	
	public ProductCTR()
	{
		dbProduct = new DBProduct();
	}
	
	public Product createProduct(String EAN, String name, String description, double price, int stock, int minStock)
	{
		Product product = new Product(EAN, name, description, price, stock, minStock);
		return product;
	}
	
	public void insertProduct(String EAN, String name, String description, double price, int stock, int minStock)
	{
		Product product = createProduct(EAN, name, description, price, stock, minStock);
		dbProduct.insertProduct(product);
	}
	
	public Product getProduct(String ean)
	{
		return dbProduct.findProduct(ean);
	}
	
	public void updateProduct(String oldEAN, String EAN, String name, String description, double price, int stock, int minStock)
	{
		Product product = createProduct(EAN, name, description, price, stock, minStock);
		dbProduct.updataProduct(product, oldEAN);
	}
	
	public void deleteProduct(String ean)
	{
		dbProduct.removeProduct(ean);
	}
}
